 <?php

 if(empty($request_new_password)){$request_new_password="";}
 if(empty($action)){$action="";}

 if($request_new_password=='yes')
 {
 if(validate_email($email)=='no')
 {
 $error_message[]='Invalid email address.';
 }
 else
 {
 $user_info = get_user_info_by_email($email);
 if($user_info['id']!='')
 {
 $user_key = $user_info['retrive_key'];
 
 $forget_password_message = "we recived a request to reset your passwword 
 if you send this request please click the following link to reset your password <a href='"
 .curPageURL()
 ."?page=forget_password&action=retrieve_password&key=".$user_key."'>"
 .curPageURL()
 ."?page=forget_password&action=retrieve_password&key=".$user_key."</a>
 if you didnt send this request just ignore this message
 ";
 
 mail($user_info['email'], read_option('site_name'), $forget_password_message);
 //echo $forget_password_message;
 $forget_password = "an email message is sent to your email address please check your email inbox for details how to reset your password";
 }
 
 }
 }
 
 if($action=='')
 {
 $forget_password = "
 <form method='post' action='index.php'>
 email address: 
 <input type='text' name='email' \>
 <input type='hidden' name='page' value='forget_password' />
 <input type='hidden' name='request_new_password' value='yes' />
 <input type='submit' value='request username / password now'/>
 </form>
 ";
 }
 ?>